package com.punai.prodatalibrary.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.enums.BusinessType;
import com.punai.prodatalibrary.domain.LibProject;
import com.punai.prodatalibrary.service.ILibProjectService;
import com.punai.common.utils.poi.ExcelUtil;
import com.punai.common.core.page.TableDataInfo;

/**
 * 项目主表Controller
 * 
 * @author tj
 * @date 2023-03-31
 */
@RestController
@RequestMapping("/prodatalibrary/libProject")
public class LibProjectController extends BaseController
{
    @Autowired
    private ILibProjectService libProjectService;

    /**
     * 查询项目主表列表
     */
    @PreAuthorize("@ss.hasPermi('prodatalibrary:libProject:list')")
    @GetMapping("/list")
    public TableDataInfo list(LibProject libProject)
    {
        startPage();
        List<LibProject> list = libProjectService.selectLibProjectList(libProject);
        return getDataTable(list);
    }

    /**
     * 获取项目主表详细信息
     */
    @PreAuthorize("@ss.hasPermi('prodatalibrary:libProject:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(libProjectService.selectLibProjectById(id));
    }

    /**
     * 新增项目主表
     */
    @PreAuthorize("@ss.hasPermi('prodatalibrary:libProject:add')")
    @Log(title = "项目主表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LibProject libProject)
    {
        return toAjax(libProjectService.insertLibProject(libProject));
    }

    /**
     * 修改项目主表
     */
    @PreAuthorize("@ss.hasPermi('prodatalibrary:libProject:edit')")
    @Log(title = "项目主表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LibProject libProject)
    {
        return toAjax(libProjectService.updateLibProject(libProject));
    }

    /**
     * 删除项目主表
     */
    @PreAuthorize("@ss.hasPermi('prodatalibrary:libProject:remove')")
    @Log(title = "项目主表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(libProjectService.deleteLibProjectByIds(ids));
    }
}
